{% extends "element/saas/statistics/statistics_base.html" %}

{% block meta_title %}地区产业分布{% endblock %}
{#更多筛选#}
{% block shaixuan_more_box %}
    <div class="sta_selected" id="sta_comstatus">企业状态：
        <div class="sta_selecttext">全部</div>
        <a href="javascript:void(0)" class="sta_clearbtn"
           onclick="clearselect('sta_comstatus')">清除</a>
    </div>
{% endblock %}

{% block shaixuan_more %}
    <h4 class="report-title">企业状态</h4>
    <div id="sta_statusbox">
        <p onclick="sta_change(1,this)" class="statusitem">在营</p>

        <p onclick="sta_change(2,this)" class="statusitem">吊销</p>

        <p onclick="sta_change(3,this)" class="statusitem">注销</p>
    </div>
{% endblock %}

{% block chart2 %}{% endblock %}

{% block comlist %}
    {{ block.super }}
    <div name="comhistogram" title="企业年龄结构" iconCls="icon-charts"></div>
{% endblock %}

{% block htmljs %}
    <script>
        mini.parse();
        var tabs = mini.get("mainTabs");
        var selectstatus = "", selectregion = "", selectnic = "", semaptype = "";
        $(function () {
            ajaxchart("", "");
        });
        maplegendtext = "企业", tablehead = "chain";
        //ajax
        function ajaxchart(region, nic, maptype) {
            selectregion = region;
            selectnic = nic;
            semaptype = maptype;
            maptype = jQuery.parseJSON(json1)[maptype];
            $.ajax({
                type: 'POST',
                url: '/saas/statistics_chain/',
                data: {
                    region: region,
                    nic: nic,
                    ENTSTATUS: selectstatus
                },
                success: function (data) {
                    if (data.noauth) {

                    } else {
                        chartautoSize(1);
                        saaschart(data, maptype);
                    }
                }
            });
            var tabname = tabs.getActiveTab().name;
            if (tabname == "comlist" || tabname == "comhistogram") {
                tabs.activeTab(0);
            }
        }
        //获取选中项
        function sta_change(id, _this) {
            if (!$(_this).hasClass("sta_active")) {
                $("#sta_statusbox .statusitem").removeClass("sta_active");
                var text = $(_this).addClass("sta_active").text();
                selectstatus = id;
                moreboxtext("sta_comstatus", text);
                ajaxchart(selectregion, selectnic, semaptype);
            }
        }
        //清除选中
        function clearselect() {
            $("#sta_statusbox .statusitem").removeClass("sta_active");
            selectstatus = "";
            moreboxtext("sta_comstatus", "");
            ajaxchart(selectregion, selectnic, semaptype);
        }
        //获取选中文字
        var _nictext = "", _regiontext = "";
        function getSelectText() {
            var tree1 = mini.get("datagrid_region"),
                node1 = tree1.getSelectedNode(),
                tree2 = mini.get("datagrid_nic"),
                node2 = tree2.getSelectedNode();
            if (node1) {
                _regiontext = node1.name;
            } else {
                _regiontext = "";
            }
            if (node2) {
                _nictext = node2.name;
            } else {
                _nictext = "";
            }
        }
        tabs.on("activechanged", function (e) {
            var index = e.index;
            if (index == 2) {
                var tab = tabs.getActiveTab();
                var taburl = tab.url;
                var url = "/saas/statistics_bangdan/?region=" + selectregion + "&nic=" + selectnic + "&ENTSTATUS=" + selectstatus;
                if (url != taburl) {
                    tabs.loadTab(url, tab, ahei);
                }
            }
            else if (index == 3) {
                var tab2 = tabs.getActiveTab();
                var taburl2 = tab2.url;
                getSelectText();
                var url2 = "/saas/statistics_histogram/?region=" + selectregion + "&nic=" + selectnic + "&regionText=" + _regiontext + "&nicText=" + _nictext;
                if (url2 != taburl2) {
                    tabs.loadTab(url2, tab2, aheih);
                }
            }
        });
        function ahei() {
            var tab = tabs.getActiveTab();
            var iframe = tabs.getTabIFrameEl(tab);
            iframe.style.height = "1600px";
        }
        function aheih() {
            var tab = tabs.getActiveTab();
            var iframe = tabs.getTabIFrameEl(tab);
            iframe.style.height = "900px";
        }
    </script>
{% endblock %}
